from tests.rypark_background.get_cookie import *
from common.config import *
import requests


class AfterPay:
    # =====================内部后台=====================
    # 运营后台无感绑定记录
    def afterpay_list(self, env, status, source, plateno=None, phone=None, parkName=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/parkFile/list"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"status": status,
                "source": source,
                "plateno": plateno,
                "phone": phone,
                "parkName": parkName}
        return requests.post(url, headers=headers, json=dict).json()

    # 运营后台导出无感绑定
    def afterpay_export(self, env, status=None, source=None, plateno=None, phone=None, parkName=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/afterPay/exportAfterPayByPage"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"status": status,
                "source": source,
                "plateno": plateno,
                "phone": phone,
                "parkName": parkName}
        return requests.post(url, headers=headers, json=dict).json()

    # =====================商户后台=====================
    # 商户后台无感绑定记录
    def shop_afterpay_list(self, env, status, source, plateno=None, phone=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/afterPay/selectAfterPayByPageBs"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": shop_cookies(env)}
        dict = {"status": status,
                "source": source,
                "plateno": plateno,
                "phone": phone}
        return requests.post(url, headers=headers, json=dict).json()

    # 商户后台导出无感绑定
    def shop_afterpay_export(self, env, status=None, source=None, plateno=None, phone=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "/easypark-backend/afterPay/exportAfterPayByPageBs"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": shop_cookies(env)}
        dict = {"status": status,
                "source": source,
                "plateno": plateno,
                "phone": phone}
        return requests.post(url, headers=headers, json=dict).json()